package com.gavindon.android.repo

import com.gavindon.android.base.BaseRepository
import com.gavindon.android.entity.CheckCanLookResp
import com.gavindon.android.entity.ComboResp
import com.gavindon.android.entity.OrderInfoResp
import com.gavindon.android.entity.PayResultResp
import com.gavindon.android.network.DataResult
import okhttp3.Call
import okhttp3.Callback
import okhttp3.OkHttp
import okhttp3.Response
import java.io.IOException

/**
 * description:
 * Created by liNan on  2022-3-1 10:18
 */
class ComboRepo : BaseRepository() {


    /*查询套餐信息通过套餐id*/
    suspend fun getComboInfo(id: String): DataResult<ComboResp> {
        return launchRequest {
            service.comboLstInfo(id)
        }
    }


    suspend fun generateOrderId(
        itemType: String,
        courseId: String,
        payType: String
    ): DataResult<OrderInfoResp> {
        return launchRequest { service.generateOrderId(itemType, courseId, payType) }
    }

    suspend fun wxPayQr(orderId: String): DataResult<String> {
        return launchRequest {
            service.wxPcPay(orderId)
        }
    }

    suspend fun aliPayQr(orderId: String): DataResult<String> {
        return launchRequest {
            service.aliPcPay(orderId)
        }
    }

    suspend fun checkIsPay(orderId: String): DataResult<PayResultResp> {
        return launchRequest {
            service.checkIsPay(orderId)
        }
    }

    //支付完成查看课程或者套餐是否可以观看
    suspend fun payFinish(
        orderType: String,
        packageOrCourseId: String
    ): DataResult<List<CheckCanLookResp>> {
        return launchRequest(isShowLoading = true) {
            service.findOrder(orderType, packageOrCourseId)
        }
    }

    suspend fun myCourseOrPackage(
        courseType: Int,
    ): DataResult<List<CheckCanLookResp>> {
        return launchRequest(isShowLoading = true) {
            service.myCourseOrPackage(courseType)
        }
    }
}